import 'dart:convert' show json;

import 'inspiration_info_bean.dart';

T asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }
  return null;
}

class InspirationInfoList {
  InspirationInfoList({
    this.results,
  });

  factory InspirationInfoList.fromJson(Map<String, dynamic> jsonRes) {
    if (jsonRes == null) {
      return null;
    }

    final List<InspirationInfo> results =
    jsonRes['results'] is List ? <InspirationInfo>[] : null;
    if (results != null) {
      for (final dynamic item in jsonRes['results']) {
        if (item != null) {
          results
              .add(InspirationInfo.fromJson(asT<Map<String, dynamic>>(item)));
        }
      }
    }
    return InspirationInfoList(
      results: results,
    );
  }

  List<InspirationInfo> results;

  Map<String, dynamic> toJson() => <String, dynamic>{
    'results': results,
  };

  @override
  String toString() {
    return json.encode(this);
  }
}